//
//  main.m
//  递归02
//
//  Created by szcq on 2021/4/14.
//

#import <Foundation/Foundation.h>
int jieCheng(int n);
/// 任意数的阶乘
/// @param argc <#argc description#>
/// @param argv <#argv description#>
int main(int argc, const char * argv[]) {
    //求任意数阶乘
    
    int number = 0;
    
    printf("请输入正整数\n");
    
    scanf("%d",&number);
    
    int result = jieCheng(number);
    
    printf("result = %d \n",result);
    
    return 0;
}


int jieCheng(int n) {
    int result = 1;
    if (n<=1) {
        result = 1;
    } else {
        int step = jieCheng(n - 1);
        result = step * n;
    }
    return result;
}
